Skip to content

asynq: fix asyncio mock#159

Merged
994125010 merged 2 commits into
masterfrom
asyncio-mock
Jun 4, 2025
Merged

asynq: fix asyncio mock#159
994125010 merged 2 commits into
masterfrom
asyncio-mock

Conversation

@994125010

@994125010 994125010 commented Jun 4, 2025

Copy link
Copy Markdown
Contributor

We introduced asynq_to_async module but didn't add tests for mocks.

When using asynq with .asyncio in conjunction with asynq.mock_.patch on an @asynq() decorated function, the .asyncio accessor leads to a a MagicMock and can't be awaited

This fixes that and adds unit tests

994125010 added 2 commits June 4, 2025 05:32
Reviewers: dkang

Test Plan: unit tests

Differential Revision:

Asana Tasks:

Screenshot:

CC:

Deploy To:
Comment thread asynq/mock_.py
# so we can also mock non-functions for compatibility
if callable(mock_fn):
async_fn = _AsyncWrapper(mock_fn)
async_fn = _AsynqWrapper(mock_fn)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed this since the attribute had to be renamed asynq to not be confused with async keyword

@994125010 994125010 merged commit ea2e317 into master Jun 4, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants